For this project the location information is one of the defining aspects of the project and future developments. The data is entered into the table as the raw variable called “Exposure.Location”. This is the baseline gps information we are able to obtain from the data. There are a several packages that allow for these functions to work.
library()
Started on day …
[PRIVATE?? unverified as of sept 01]
This database can be extended however the current vertified database include exposure locations from xx date to xx data, Suburb.
Locations are reported on the ACT Health site including
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(tidyverse)
tab3 <- read_csv("https://raw.githubusercontent.com/green-striped-gecko/covid_canberra/main/data/last.csv")
## Rows: 290 Columns: 12
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (9): Status, Exposure.Location, Street, Suburb, Date, Arrival.Time, Depa...
## dbl (2): lat, lon
## lgl (1): moved
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
str(tab3)
## spec_tbl_df [290 x 12] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ Status : chr [1:290] NA NA NA NA ...
## $ Exposure.Location: chr [1:290] "Bus Route 66 Transport Canberra Code BUS355" "Bus Route 61 Transport Canberra Code BUS359" "Cooleman Court Shopping Centre" "Cooleman Court Shopping Centre - Public Toilets" ...
## $ Street : chr [1:290] "Denman Prospect to Woden Interchange" "Woden Interchange to Phillip" "Brierly Street" "Brierly Street" ...
## $ Suburb : chr [1:290] "Public Transport" "Public Transport" "Weston" "Weston" ...
## $ Date : chr [1:290] "31/08/2021 - Tuesday" "31/08/2021 - Tuesday" "31/08/2021 - Tuesday" "31/08/2021 - Tuesday" ...
## $ Arrival.Time : chr [1:290] "7:27pm" "7:46pm" "12:00pm" "12:15pm" ...
## $ Departure.Time : chr [1:290] "7:43pm" "7:50pm" "1:00pm" "12:45pm" ...
## $ Contact : chr [1:290] "Casual" "Casual" "Monitor" "Casual" ...
## $ lat : num [1:290] -35.3 -35.3 -35.3 -35.3 -35.3 ...
## $ lon : num [1:290] 149 149 149 149 149 ...
## $ doubles : chr [1:290] NA NA NA NA ...
## $ moved : logi [1:290] FALSE FALSE FALSE FALSE FALSE FALSE ...
## - attr(*, "spec")=
## .. cols(
## .. Status = col_character(),
## .. Exposure.Location = col_character(),
## .. Street = col_character(),
## .. Suburb = col_character(),
## .. Date = col_character(),
## .. Arrival.Time = col_character(),
## .. Departure.Time = col_character(),
## .. Contact = col_character(),
## .. lat = col_double(),
## .. lon = col_double(),
## .. doubles = col_character(),
## .. moved = col_logical()
## .. )
## - attr(*, "problems")=<externalptr>
# names(tab3)
datyl <-factor(tab3$Contact)
# levels(datyl)
datyl1 <- tab3 %>%
filter(Status >= "New")
names(tab3)
## [1] "Status" "Exposure.Location" "Street"
## [4] "Suburb" "Date" "Arrival.Time"
## [7] "Departure.Time" "Contact" "lat"
## [10] "lon" "doubles" "moved"
# colsN <- cols[datyl1]
tab4 <- tab3 %>%
mutate(colsN = factor(Contact, levels = c("Close", "Casual", "Monitor","Investigation location")),
Contact = factor(Contact, levels = c("Close", "Casual","Monitor", "Investigation location")))
levels(tab4$colsN) <- c("purple", "red","orange", "grey50")
levels(tab4$colsN) <- c( "yellow", "red","cyan", "blue")
table(tab4$colsN)
##
## yellow red cyan blue
## 16 97 177 0
names(tab4)
## [1] "Status" "Exposure.Location" "Street"
## [4] "Suburb" "Date" "Arrival.Time"
## [7] "Departure.Time" "Contact" "lat"
## [10] "lon" "doubles" "moved"
## [13] "colsN"
tab4 %>%
mutate(conDate = as.Date(lubridate::dmy(Date)),
locName = as.factor(Exposure.Location))
##loc summaries
tab5 <- tab4 %>%
mutate(conDate = as.Date(lubridate::dmy(Date)),
locName = as.factor(Suburb))
a <- as.data.frame(table(tab5$locName))
colnames(a) <- c("locName", "contactcount")
# head(a)
# str(a)
# filter(a, contactcount >=1)
plotsumms <- right_join(tab5, a)
## Joining, by = "locName"
print(a)
## locName contactcount
## 1 Ainslie 2
## 2 Amaroo 7
## 3 Barton 1
## 4 Belconnen 15
## 5 Braddon 6
## 6 Braddon & Turner 1
## 7 Calwell 3
## 8 Campbell 7
## 9 Canberra City 14
## 10 Casey 12
## 11 Charnwood 3
## 12 Chifley 1
## 13 Chisholm 14
## 14 Conder 12
## 15 Crace 1
## 16 Denman Prospect 1
## 17 Dickson 9
## 18 Evatt 1
## 19 Florey 4
## 20 Franklin 2
## 21 Fyshwick 19
## 22 Greenway 13
## 23 Griffith 2
## 24 Gungahlin 20
## 25 Holt 13
## 26 Lyneham 1
## 27 Macquarie 3
## 28 Majura Park 3
## 29 Mawson 10
## 30 Mitchell 3
## 31 Narrabundah 4
## 32 Ngunnawal 3
## 33 Nicholls 2
## 34 Palmerston 2
## 35 Phillip 25
## 36 Pialligo 1
## 37 Public Transport 14
## 38 Turner 2
## 39 Wanniassa 12
## 40 Watson 4
## 41 Weston 16
## 42 Woden 2
str(a)
## 'data.frame': 42 obs. of 2 variables:
## $ locName : Factor w/ 42 levels "Ainslie","Amaroo",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ contactcount: int 2 7 1 15 6 1 3 7 14 12 ...
# Aggregate method
# labs <- paste(plotsumms$Exposure.Location, plotsumms$Date,plotsumms$Arrival.Time, plotsumms$Departure.Time, sep="<br/>")
nrow(tab4)
## [1] 290
#> [1] 100
nrow(distinct(plotsumms, Suburb))
## [1] 42
b <- distinct(plotsumms, Suburb, .keep_all = TRUE)
# subsTable <- semi_join(tab4, b)
#> [1] 69
# nrow(distinct(df, x, y))
# #> [1] 69
levels(plotsumms$locName)
## [1] "Ainslie" "Amaroo" "Barton" "Belconnen"
## [5] "Braddon" "Braddon & Turner" "Calwell" "Campbell"
## [9] "Canberra City" "Casey" "Charnwood" "Chifley"
## [13] "Chisholm" "Conder" "Crace" "Denman Prospect"
## [17] "Dickson" "Evatt" "Florey" "Franklin"
## [21] "Fyshwick" "Greenway" "Griffith" "Gungahlin"
## [25] "Holt" "Lyneham" "Macquarie" "Majura Park"
## [29] "Mawson" "Mitchell" "Narrabundah" "Ngunnawal"
## [33] "Nicholls" "Palmerston" "Phillip" "Pialligo"
## [37] "Public Transport" "Turner" "Wanniassa" "Watson"
## [41] "Weston" "Woden"
# distinct(df, x)
plotsumms <- b
plotsumms$Suburb[35] <- "O'Connor"
plotsumms$locName[35] <- "O'Connor"
## Warning in `[<-.factor`(`*tmp*`, 35, value = structure(c(37L, 41L, 21L, :
## invalid factor level, NA generated
# plotsumms$Suburb <- droplevels(plotsumms$Suburb)
# plotsumms$locName <- droplevels(plotsumms$locName)
clean <- plotsumms$Exposure.Location[4] <- "Assembly The People Pub"
# pre-processing
# ensure that all characters in the `Name` column
# are valid UTF-8 encoded
# Thank you to SO for this gem
# https://stackoverflow.com/questions/17291287/how-to-identify-delete-non-utf-8-characters-in-r
Encoding(x = plotsumms$Exposure.Location) <- "UTF-8"
# replace all non UTF-8 character strings with an empty space
plotsumms$Exposure.Location <-
iconv( x = plotsumms$Exposure.Location
, from = "UTF-8"
, to = "UTF-8"
, sub = "" )
labs <- paste(plotsumms$Exposure.Location, plotsumms$Date,plotsumms$Arrival.Time, plotsumms$Departure.Time, sep="<br/>")
leaflet(plotsumms) %>% addTiles() %>%
addCircleMarkers(lat=plotsumms$lat,
lng=plotsumms$lon,
weight = 0.2,
radius = log(plotsumms$contactcount)*5,
color = plotsumms$colsN,
stroke = TRUE,
fill = rep("black", length(plotsumms$colsN)),
popup = paste0(" COUNT:", plotsumms$contactcount),
fillOpacity = 0.8
) %>%
addCircles(lat=tab4$lat,lng=tab4$lon,
popup = paste0(plotsumms$Exposure.Location," ", plotsumms$Date))
# %>%
# group_by(locName) %>%
# summarise(countPlace = count(Place))
# # %>%
# group_by(Suburb) %>%
# summarise(FirstCase = min(conDate),
# LastCase = max(conDate),
# caseCount = sum(unique(Place)))
# write.csv(x = plotsumms, "data/outSubs.csv")
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
This needs to account for projection, crs, points, polygons, SA levels etc…
Locations are reported on the ACT Health site including
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
library(lubridate)
library(tidyverse)
tab3 <- read_csv("https://raw.githubusercontent.com/green-striped-gecko/covid_canberra/main/data/last.csv")
## Rows: 290 Columns: 12
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (9): Status, Exposure.Location, Street, Suburb, Date, Arrival.Time, Depa...
## dbl (2): lat, lon
## lgl (1): moved
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
str(tab3)
## spec_tbl_df [290 x 12] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ Status : chr [1:290] NA NA NA NA ...
## $ Exposure.Location: chr [1:290] "Bus Route 66 Transport Canberra Code BUS355" "Bus Route 61 Transport Canberra Code BUS359" "Cooleman Court Shopping Centre" "Cooleman Court Shopping Centre - Public Toilets" ...
## $ Street : chr [1:290] "Denman Prospect to Woden Interchange" "Woden Interchange to Phillip" "Brierly Street" "Brierly Street" ...
## $ Suburb : chr [1:290] "Public Transport" "Public Transport" "Weston" "Weston" ...
## $ Date : chr [1:290] "31/08/2021 - Tuesday" "31/08/2021 - Tuesday" "31/08/2021 - Tuesday" "31/08/2021 - Tuesday" ...
## $ Arrival.Time : chr [1:290] "7:27pm" "7:46pm" "12:00pm" "12:15pm" ...
## $ Departure.Time : chr [1:290] "7:43pm" "7:50pm" "1:00pm" "12:45pm" ...
## $ Contact : chr [1:290] "Casual" "Casual" "Monitor" "Casual" ...
## $ lat : num [1:290] -35.3 -35.3 -35.3 -35.3 -35.3 ...
## $ lon : num [1:290] 149 149 149 149 149 ...
## $ doubles : chr [1:290] NA NA NA NA ...
## $ moved : logi [1:290] FALSE FALSE FALSE FALSE FALSE FALSE ...
## - attr(*, "spec")=
## .. cols(
## .. Status = col_character(),
## .. Exposure.Location = col_character(),
## .. Street = col_character(),
## .. Suburb = col_character(),
## .. Date = col_character(),
## .. Arrival.Time = col_character(),
## .. Departure.Time = col_character(),
## .. Contact = col_character(),
## .. lat = col_double(),
## .. lon = col_double(),
## .. doubles = col_character(),
## .. moved = col_logical()
## .. )
## - attr(*, "problems")=<externalptr>
# names(tab3)
datyl <-factor(tab3$Contact)
# levels(datyl)
datyl1 <- tab3 %>%
filter(Status >= "New")
names(tab3)
## [1] "Status" "Exposure.Location" "Street"
## [4] "Suburb" "Date" "Arrival.Time"
## [7] "Departure.Time" "Contact" "lat"
## [10] "lon" "doubles" "moved"
# colsN <- cols[datyl1]
tab4 <- tab3 %>%
mutate(colsN = factor(Contact, levels = c("Close", "Casual", "Monitor","Investigation location")),
Contact = factor(Contact, levels = c("Close", "Casual","Monitor", "Investigation location")))
levels(tab4$colsN) <- c("purple", "red","orange", "grey50")
levels(tab4$colsN) <- c( "yellow", "red","cyan", "blue")
table(tab4$colsN)
##
## yellow red cyan blue
## 16 97 177 0
names(tab4)
## [1] "Status" "Exposure.Location" "Street"
## [4] "Suburb" "Date" "Arrival.Time"
## [7] "Departure.Time" "Contact" "lat"
## [10] "lon" "doubles" "moved"
## [13] "colsN"
tab4 %>%
mutate(conDate = as.Date(lubridate::dmy(Date)),
locName = as.factor(Exposure.Location))
##loc summaries
tab5 <- tab4 %>%
mutate(conDate = as.Date(lubridate::dmy(Date)),
locName = as.factor(Suburb))
a <- as.data.frame(table(tab5$locName))
colnames(a) <- c("locName", "contactcount")
# head(a)
# str(a)
# filter(a, contactcount >=1)
plotsumms <- right_join(tab5, a)
## Joining, by = "locName"
print(a)
## locName contactcount
## 1 Ainslie 2
## 2 Amaroo 7
## 3 Barton 1
## 4 Belconnen 15
## 5 Braddon 6
## 6 Braddon & Turner 1
## 7 Calwell 3
## 8 Campbell 7
## 9 Canberra City 14
## 10 Casey 12
## 11 Charnwood 3
## 12 Chifley 1
## 13 Chisholm 14
## 14 Conder 12
## 15 Crace 1
## 16 Denman Prospect 1
## 17 Dickson 9
## 18 Evatt 1
## 19 Florey 4
## 20 Franklin 2
## 21 Fyshwick 19
## 22 Greenway 13
## 23 Griffith 2
## 24 Gungahlin 20
## 25 Holt 13
## 26 Lyneham 1
## 27 Macquarie 3
## 28 Majura Park 3
## 29 Mawson 10
## 30 Mitchell 3
## 31 Narrabundah 4
## 32 Ngunnawal 3
## 33 Nicholls 2
## 34 Palmerston 2
## 35 Phillip 25
## 36 Pialligo 1
## 37 Public Transport 14
## 38 Turner 2
## 39 Wanniassa 12
## 40 Watson 4
## 41 Weston 16
## 42 Woden 2
str(a)
## 'data.frame': 42 obs. of 2 variables:
## $ locName : Factor w/ 42 levels "Ainslie","Amaroo",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ contactcount: int 2 7 1 15 6 1 3 7 14 12 ...
# Aggregate method
# labs <- paste(plotsumms$Exposure.Location, plotsumms$Date,plotsumms$Arrival.Time, plotsumms$Departure.Time, sep="<br/>")
nrow(tab4)
## [1] 290
#> [1] 100
nrow(distinct(plotsumms, Suburb))
## [1] 42
b <- distinct(plotsumms, Suburb, .keep_all = TRUE)
# subsTable <- semi_join(tab4, b)
#> [1] 69
# nrow(distinct(df, x, y))
# #> [1] 69
levels(plotsumms$locName)
## [1] "Ainslie" "Amaroo" "Barton" "Belconnen"
## [5] "Braddon" "Braddon & Turner" "Calwell" "Campbell"
## [9] "Canberra City" "Casey" "Charnwood" "Chifley"
## [13] "Chisholm" "Conder" "Crace" "Denman Prospect"
## [17] "Dickson" "Evatt" "Florey" "Franklin"
## [21] "Fyshwick" "Greenway" "Griffith" "Gungahlin"
## [25] "Holt" "Lyneham" "Macquarie" "Majura Park"
## [29] "Mawson" "Mitchell" "Narrabundah" "Ngunnawal"
## [33] "Nicholls" "Palmerston" "Phillip" "Pialligo"
## [37] "Public Transport" "Turner" "Wanniassa" "Watson"
## [41] "Weston" "Woden"
# distinct(df, x)
plotsumms <- b
plotsumms$Suburb[35] <- "O'Connor"
plotsumms$locName[35] <- "O'Connor"
## Warning in `[<-.factor`(`*tmp*`, 35, value = structure(c(37L, 41L, 21L, :
## invalid factor level, NA generated
# plotsumms$Suburb <- droplevels(plotsumms$Suburb)
# plotsumms$locName <- droplevels(plotsumms$locName)
clean <- plotsumms$Exposure.Location[4] <- "Assembly The People Pub"
# pre-processing
# ensure that all characters in the `Name` column
# are valid UTF-8 encoded
# Thank you to SO for this gem
# https://stackoverflow.com/questions/17291287/how-to-identify-delete-non-utf-8-characters-in-r
Encoding(x = plotsumms$Exposure.Location) <- "UTF-8"
# replace all non UTF-8 character strings with an empty space
plotsumms$Exposure.Location <-
iconv( x = plotsumms$Exposure.Location
, from = "UTF-8"
, to = "UTF-8"
, sub = "" )
labs <- paste(plotsumms$Exposure.Location, plotsumms$Date,plotsumms$Arrival.Time, plotsumms$Departure.Time, sep="<br/>")
leaflet(plotsumms) %>% addTiles() %>%
addCircleMarkers(lat=plotsumms$lat,
lng=plotsumms$lon,
weight = 0.2,
radius = log(plotsumms$contactcount)*5,
color = plotsumms$colsN,
stroke = TRUE,
fill = rep("black", length(plotsumms$colsN)),
popup = paste0(" COUNT:", plotsumms$contactcount),
fillOpacity = 0.8
) %>%
addCircles(lat=tab4$lat,lng=tab4$lon,
popup = paste0(plotsumms$Exposure.Location," ", plotsumms$Date))
# %>%
# group_by(locName) %>%
# summarise(countPlace = count(Place))
# # %>%
# group_by(Suburb) %>%
# summarise(FirstCase = min(conDate),
# LastCase = max(conDate),
# caseCount = sum(unique(Place)))
# write.csv(x = plotsumms, "data/outSubs.csv")
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
Overall we can group locations and other attributes into different spatial areas. For mapping many projects the exact location is not know or is not needed/wanted for a range of obvious reasons. This set of functions takes the location information from each of the datasets and creates a uniform location entry that aligns with the desired spatial scale.
Here I have created for groups: North Canberra, Central Canberra,…..
This package allows aspects of this data to be linked with census and other data resources associated with this level of geo-spatial identification.
Overall we can group locations and other attributes into different spatial areas. Here I have created for groups: North Canberra, Central Canberra,…..
Manual grouping into four general areas….
This package allows aspects of this data to be linked with census and other data resources associated with this level of geo-spatial identification.
All current locations in cases